package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjaftersales;
import com.chezhujie.www.persistence.CzjaftersalesMapper;
import com.xy.core.exception.ClassCheckException;
import com.xy.user.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 售后服务
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjaftersalesService extends BaseService<Czjaftersales> {
    @Autowired
    private CzjaftersalesMapper czjaftersalesMapper;

    @Autowired
    public void setBaseMapper(CzjaftersalesMapper czjaftersalesMapper) {
        this.baseMapper = czjaftersalesMapper;
    }


    public void checkEntity(Czjaftersales czjaftersales) throws ClassCheckException {
        if(czjaftersales.getAftersalesId()!=null&&czjaftersales.getAftersalesId().length()>19){
            throw new ClassCheckException("售后服务主键不能超过19个字符");
        }
        if(czjaftersales.getCommodityId()!=null&&czjaftersales.getCommodityId().length()>19){
            throw new ClassCheckException("售后服务商品不能超过19个字符");
        }
        if(czjaftersales.getName()!=null&&czjaftersales.getName().length()>19){
            throw new ClassCheckException("售后服务售后服务名称不能超过19个字符");
        }
        if(czjaftersales.getValue()!=null&&czjaftersales.getValue().length()>255){
            throw new ClassCheckException("售后服务售后服务内容不能超过255个字符");
        }
    }
    public void checkListEntity(List<Czjaftersales> listCzjaftersales) throws ClassCheckException {

        for (Czjaftersales czjaftersales : listCzjaftersales) {
            checkEntity(czjaftersales);
        }

    }


	public List<Czjaftersales> getAfterByCommid(String id) {
		return czjaftersalesMapper.getAfterByCommid(id);
	}
}
